var maxDepth = function(root) {
    let res=0
    if(!root) return res
    let queue = [root]

    while(queue.length){
        let length =queue.length
        for(let i=0;i<length;i++){
            let node = queue.shift()
            node.left&&queue.push(node.left)
            node.right&&queue.push(node.right)
        }
        res++
    }
    return res
};